package auxiliary;

import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;

import javax.swing.ImageIcon;
import javax.swing.JComponent;
import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;

public class GercoTable extends JTable {

	 public GercoTable( javax.swing.table.TableModel dataModel ) {
	        super( dataModel );
	 }

	
   final ImageIcon image = new ImageIcon("background.png");

   @Override
   public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
       final Component c = super.prepareRenderer(renderer, row, column);
       if (c instanceof JComponent){
           ((JComponent) c).setOpaque(false);                    
       }
       return c;
   }

   @Override
   public void paint(Graphics g) {
       //draw image in centre
       final int imageWidth = image.getIconWidth();
       final int imageHeight = image.getIconHeight();
       final Dimension d = getSize();
       final int x = (d.width - imageWidth)/2;
       final int y = (d.height - imageHeight)/2;
       g.drawImage(image.getImage(), x, y, null, null);
       super.paint(g);
   }
}